package com.yidu.BusinessData.service.impl;

import com.yidu.BusinessData.entity.StockEntity;
import com.yidu.BusinessData.mapper.StockMapper;
import com.yidu.BusinessData.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**@description: 板块分类Impl
 *@author: 肖理
 *@create: 2022-09-10
 **/
@Service
public class StockImpl implements StockService {
    @Autowired
    StockMapper stockMapper;//,int page,int limit
    @Override
    public List<StockEntity> selectStock(String stockName) {
        Map map=new HashMap();
        map.put("stockName",stockName);
//        map.put("page",(page-1)*limit);
//        map.put("limit",limit);
        return stockMapper.selectStock(map);
    }

    @Override
    public List<StockEntity> selectStocktwo() {
        return stockMapper.selectStocktwo();
    }

    @Override
    public List<StockEntity> selectStockthree() {
        return stockMapper.selectStockthree();
    }

    @Override
    public int insertStock(StockEntity stockEntity) {
        return stockMapper.insertStock(stockEntity);
    }

    @Override
    public int deleteStock(String stockId) {
        String[] split = stockId.split(",");
        ArrayList<Object> list=new ArrayList<>();
        int i = 0;
        for (String id : split) {
            list.add(id);
            i = stockMapper.deleteStock(id);
        }
        System.out.println(list);
        return i;
    }

    @Override
    public int updateStock(StockEntity stockEntity) {
        return stockMapper.updateStock(stockEntity);
    }
}
